package com.web.windy.controller;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.web.windy.pojo.User;
import com.web.windy.service.IUserService;

@Controller //对应表现层的bean，也就是action
@RequestMapping("/user")  //requestMapping是一个用来处理请求地址映射的注解，可用于类或方法上。用于类上，表示勒种的所有响应请求的方法都是以该地址作为父路径
public class UserController {
	@Resource
	private IUserService userService;
	
	@RequestMapping("/showUser")   //显示用户的action路径为action="/Demo/user/showUser"
	public String toIndex(HttpServletRequest request,Model model){
		int userId = Integer.parseInt(request.getParameter("id"));
		User user = this.userService.getUserById(userId);
		model.addAttribute("user", user);
		return "showUser";   //路径WEB-INF/jsp/showUser.jsp
	}
	
}
